package com.rt.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rt.common.annotation.Log;
import com.rt.common.core.controller.BaseController;
import com.rt.common.core.domain.AjaxResult;
import com.rt.common.enums.BusinessType;
import com.rt.system.domain.RtAssemblyKnowledge;
import com.rt.system.service.IRtAssemblyKnowledgeService;
import com.rt.common.utils.poi.ExcelUtil;
import com.rt.common.core.page.TableDataInfo;

/**
 * 策略知识点Controller
 * 
 * @author Yg
 * @date 2022-05-05
 */
@RestController
@RequestMapping("/system/assemblyknowledge")
public class RtAssemblyKnowledgeController extends BaseController
{
    @Autowired
    private IRtAssemblyKnowledgeService rtAssemblyKnowledgeService;

    /**
     * 查询策略知识点列表
     */
    @PreAuthorize("@ss.hasPermi('system:knowledge:list')")
    @GetMapping("/list")
    public TableDataInfo list(RtAssemblyKnowledge rtAssemblyKnowledge)
    {
        startPage();
        List<RtAssemblyKnowledge> list = rtAssemblyKnowledgeService.selectRtAssemblyKnowledgeList(rtAssemblyKnowledge);
        return getDataTable(list);
    }

    /**
     * 导出策略知识点列表
     */
    @PreAuthorize("@ss.hasPermi('system:knowledge:export')")
    @Log(title = "策略知识点", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RtAssemblyKnowledge rtAssemblyKnowledge)
    {
        List<RtAssemblyKnowledge> list = rtAssemblyKnowledgeService.selectRtAssemblyKnowledgeList(rtAssemblyKnowledge);
        ExcelUtil<RtAssemblyKnowledge> util = new ExcelUtil<RtAssemblyKnowledge>(RtAssemblyKnowledge.class);
        return util.exportExcel(list, "策略知识点数据");
    }

    /**
     * 获取策略知识点详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:knowledge:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rtAssemblyKnowledgeService.selectRtAssemblyKnowledgeById(id));
    }

    /**
     * 新增策略知识点
     */
    @PreAuthorize("@ss.hasPermi('system:knowledge:add')")
    @Log(title = "策略知识点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RtAssemblyKnowledge rtAssemblyKnowledge)
    {
        return toAjax(rtAssemblyKnowledgeService.insertRtAssemblyKnowledge(rtAssemblyKnowledge));
    }

    /**
     * 修改策略知识点
     */
    @PreAuthorize("@ss.hasPermi('system:knowledge:edit')")
    @Log(title = "策略知识点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RtAssemblyKnowledge rtAssemblyKnowledge)
    {
        return toAjax(rtAssemblyKnowledgeService.updateRtAssemblyKnowledge(rtAssemblyKnowledge));
    }

    /**
     * 删除策略知识点
     */
    @PreAuthorize("@ss.hasPermi('system:knowledge:remove')")
    @Log(title = "策略知识点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rtAssemblyKnowledgeService.deleteRtAssemblyKnowledgeByIds(ids));
    }
}
